<?php
abstract class AbstractController extends Zend_Controller_Action {
	
	public function init() {
		parent::init();
		
		AppContext::setRequest($this->getRequest());
		
		if (!SecurityContext::instance()->authorize($this->getRequest())) {
			RedirectHandler::instance()->doRedirect(
				SecurityContext::instance()->getAuthenticationUrl());
		}
		
		require_once AppContext::getApplicationPath() . 'etc/i18n/lang.en.php';
		Translator::setup($lang);
		
		$file = 'share/css/'. AppContext::getControllerName() .'.css';
		
		if (ZLib_File::exist(AppContext::getApplicationPath() . $file)) {
			$this->headLink()->appendStylesheet(AppContext::getBaseURL() . $file);
		}
		
		$file = 'share/js/'. AppContext::getControllerName() .'.js';
		
		if (ZLib_File::exist(AppContext::getApplicationPath() . $file)) {
			$this->headScript()->appendFile(AppContext::getBaseURL() . $file);
		}
	}
}